<template>
  <div :class="getClass">
    <template v-if="canFullscreen">
      <a-tooltip title="还原" placement="bottom" v-if="fullScreen">
        <FullscreenExitOutlined role="full" @click="handleFullScreen" />
      </a-tooltip>
      <a-tooltip title="最大化" placement="bottom" v-else>
        <FullscreenOutlined role="close" @click="handleFullScreen" />
      </a-tooltip>
    </template>
    <div class="close-modal" @click="handleCancel">
      <IconFont iconType="icon-close_icon" />
    </div>
    <!-- <CloseOutlined @click="handleCancel" /> -->
  </div>
</template>
<script lang="ts">
import { defineComponent, computed } from 'vue'
import { FullscreenExitOutlined, FullscreenOutlined, CloseOutlined } from '@ant-design/icons-vue'
import IconFont from '@/components/IconFont/index.vue'

export default defineComponent({
  name: 'ModalClose',
  components: { FullscreenExitOutlined, FullscreenOutlined, CloseOutlined, IconFont },
  props: {
    canFullscreen: { type: Boolean, default: true },
    fullScreen: { type: Boolean }
  },
  emits: ['cancel', 'fullscreen'],
  setup(props, { emit }) {
    const getClass = computed(() => {
      return [
        'basic-modal-close',
        `basic-modal-close--custom`,
        {
          [`basic-modal-close--can-full`]: props.canFullscreen
        }
      ]
    })

    function handleCancel(e: Event) {
      emit('cancel', e)
    }

    function handleFullScreen(e: Event) {
      e?.stopPropagation()
      e?.preventDefault()
      emit('fullscreen')
    }

    return {
      getClass,
      handleCancel,
      handleFullScreen
    }
  }
})
</script>
<style lang="less">
.basic-modal-close {
  display: flex;
  height: 95%;
  align-items: center;

  > span {
    // margin-left: 48px;
    font-size: 16px;
  }

  &--can-full {
    > span {
      margin-left: 12px;
    }
  }

  &:not(&--can-full) {
    > span:nth-child(1) {
      &:hover {
        font-weight: 700;
      }
    }
  }

  & span:nth-child(1) {
    display: inline-block;
    padding: 10px;

    &:hover {
      color: #0960bd;
    }
  }
  .close-modal {
    color: #555d6f;
    font-size: 20px;
    &:hover {
      color: @primary-color;
    }
  }
  & span:last-child {
    &:hover {
      color: @primary-color;
    }
  }
}
</style>
